import ap

import requests
import unittest
from ddt import ddt, data, unpack


@ddt
class TestInterface(unittest.TestCase):

    # @data(
    #     ["117", "cancel_collect"],
    #     ["118", "cancel_collect"],
    #     ["119", "cancel_collect"],
    #     ["120", "cancel_collect"],
    #     ["121", "cancel_collect"]
    # )
    @data(*ap.allpairs([["1", "2", "3"], ["collect", "cancel_collect"]]))
    @unpack
    def test_case(self, id, action):
        cookie = {"session": "571438de-d813-49d1-b81a-b4b6dc4c89a3.O-f4reZ7N1b8_EKhQIBDc0Xj4jo"}
        header = {"Content-Type": "application/json"}
        data = ('{"news_id": "%s", "action": "%s"}' % (id, action)).encode("utf-8")
        r = requests.post("http://192.168.41.111:9999/news/news_collect", cookies=cookie, headers=header, data=data)
        print(r.json())


if __name__ == '__main__':
    unittest.main()
